package main;

import classes.QRImage;
import display.SimpleTestGUI;

/**
 * DecoderQR
 * 
 * @author Nicole Nelson
 */
public class DecoderQR 
{
	/*
	 * Main to call and set up the Decoding process
	 */
	public static void main(String[] args) 
	{
		boolean display = true;
		int argNum = 0;
		//Gets the string input from the command line or if none is supplied from the program itself
		String fileName = "img/byui01.jpg";
		if(args.length > 0)
		{
			if(args[argNum].equals("noDis"))
			{
				display = false;
				argNum++;
			}
			while(argNum < args.length)
			{
				fileName = args[argNum];
				System.out.print(fileName + ": ");
				
				//Creates the GUI and the QRImage
				SimpleTestGUI simple = new SimpleTestGUI(fileName);
				QRImage qrImage = new QRImage(fileName);
				qrImage.setDisplay(display);
				//displays the results to the GUI
				simple.setImage(qrImage, qrImage.findCode()); 
				if(display)
					simple.displayGUI();
				argNum++;
			}
		}
		else
		{
			//Creates the GUI and the QRImage
			SimpleTestGUI simple = new SimpleTestGUI(fileName);
			QRImage qrImage = new QRImage(fileName);
			qrImage.setDisplay(display);
			//displays the results to the GUI
			simple.setImage(qrImage, qrImage.findCode()); 
			if(display)
				simple.displayGUI();
		}
	}
}